/* This code increments the histogram by the proper amount
	yes you are reading this right that is a 4-d matrix
*/

void hist4d(double **** histogram, long time, double x, double y, 
	double * xmin, double * xmax, double * xbin, double * ymin, 
	double * ymax,double * ybin, long nx, long ny, long nhist) {
  
  long x_ind=(long)floor((x-xmin[nhist])/xbin[nhist]+0.5);
  long y_ind=(long)floor((y-ymin[nhist])/ybin[nhist]+0.5);
  if (x_ind >= 0 && x_ind <= nx-1 && y_ind >= 0 && y_ind <= ny-1)  histogram[x_ind][y_ind][time][nhist]++;
}

